from PySide6.QtCore import Qt
from PySide6.QtWidgets import QDialog, QVBoxLayout, QLabel, QHBoxLayout, QPushButton

from config import APP_VERSION


class CopyrightDialog(QDialog):
    def __init__(self, parent=None):
        super(CopyrightDialog, self).__init__(parent)

        # 设置窗口标题
        self.setWindowTitle("Copyright Info")

        # 设置窗口大小
        self.resize(400, 200)

        # 创建布局
        layout = QVBoxLayout()

        # 添加版权信息标签
        copyright_label = QLabel(
            f"Copyright © 2024 JCI APAC Data Team\n\nVersion: {APP_VERSION}\n\nJerry Zang(jzangc@.jci.com)\n\nThis software is for internal use "
            "only."
            "It shall not be copied or distributed without permission.")
        copyright_label.setAlignment(Qt.AlignCenter)
        layout.addWidget(copyright_label)

        # 创建按钮布局
        button_layout = QHBoxLayout()
        button_layout.addStretch(1)  # 添加伸缩空间，使按钮居中

        # 添加关闭按钮
        close_button = QPushButton("Close")
        close_button.setFixedSize(80, 30)
        close_button.clicked.connect(self.accept)

        button_layout.addWidget(close_button)

        button_layout.addStretch(1)
        # 将按钮布局添加到主布局
        layout.addLayout(button_layout)

        # 设置布局
        self.setLayout(layout)